/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */
package bea.cliente.core;

import com.jme3.app.Application;
import com.jme3.system.AppSettings;
import java.util.Properties;

/**
 *
 * @author Ivan da Silveira
 */
public class GameSettings extends Properties {

    private Application app;
    private AppSettings settings;

    public GameSettings(AppSettings _settings) {
        settings = _settings;
    }

    public GameSettings(Application _app, AppSettings _settings) {
        app = _app;
        settings = _settings;
    }
    // KEYS
    public static final String KEY_FRAMERATE = "fps";
    public static final String KEY_WIDTH = "width";
    public static final String KEY_HEIGHT = "height";
    public static final String KEY_ANTIALAISING = "antialaising";
    public static final String KEY_FULLSCREEN = "fullscreen";
    public static final String KEY_FREQUENCY = "frequency";
    public static final String KEY_RENDERER = "renderer";
    public static final String KEY_SHADOW = "shadow";
    public static final String KEY_SHADOW_TYPE = "shadowType";
    public static final String KEY_SHADOW_LEVEL = "shadowLevel";
    public static final String KEY_PROCESSOR_CORES = "processorCores";
    // CONSTANTES
    public static final int SHADOW_PSSM = 30;
    public static final int SHADOW_BASIC = 31;

    public void setSettings(AppSettings _settings) {
        settings = _settings;
    }

    /**
     * Variavel de controle da existência de sombra no ambiente
     * @return boolean true/false (sim/não)
     */
    public boolean hasShadow() {
        return settings.getBoolean(KEY_SHADOW);
    }

    /**
     * Retorna o tipo de sombra PSSM ou BASIC
     * @return int 30(PSSM) ou 31(BASIC)
     */
    public int getShadowType() {
        return settings.getInteger(KEY_SHADOW_TYPE);
    }

    /**
     * Retorna o nível de qualidade da sombra
     * @return int de 128 a 4096
     */
    public int getShadowLevel() {
        return settings.getInteger(KEY_SHADOW_LEVEL);
    }

    /**
     * Retorna o número de processadores do computador
     * @return int número de cores
     */
    public int getProcessorCores() {
        return settings.getInteger(KEY_PROCESSOR_CORES);
    }

    /**
     * Muda a resolução atual para a passada por parametro
     * @param width nova largura
     * @param height nova altura
     */
    public void changeResolution(int width, int height) {
        settings.setResolution(width, height);
        app.restart();
    }
}